<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div id="wrapper">
    <div class="main clearfix">
        <div class="col_730">        
            <div align="center">
                <h2>Edit Session</h2>
                <table border="0" width="100%">
                    <form:form action="${baseUrl}/cp/savesessiondetail.html" method="POST" commandName="sessionForm">
                        <tr>
                            <td>Year</td>
                            <td><form:input path="year" value="${dataSession.year}" size="30"/></td>
                            <td><form:errors path="year" cssClass="error"/></td>
                        </tr>
                        <tr>
                            <td align="left" width="20%">Semester </td>
                            <td align="left" width="40%">
                                <form:select path="semester">
                                    <c:choose>
                                        <c:when test="${dataSession.semester == 1}">
                                            <form:option value="1" selected="selected" label="1st semester"/>
                                            <form:option value="2" label="2nd semester"/>
                                        </c:when>
                                        <c:when test="${dataSession.semester == 2}">
                                            <form:option value="1" label="1st semester"/>
                                            <form:option value="2" selected="selected" label="2nd semester"/>
                                        </c:when>
                                        <c:otherwise>
                                            <form:option value="1" label="1st semester"/>
                                            <form:option value="2" label="2nd semester"/>
                                        </c:otherwise>
                                    </c:choose>
                                </form:select>
                            </td>
                            <td align="left"><form:errors path="semester" cssClass="error"/></td>
                        </tr>

                        <tr>
                            <td><form:hidden path="id" value="${dataSession.session_id}"/></td>
                            <td align="left">
                                <input type="submit" value="Edit"/>
                                <input type="button" onclick="formCancel('${baseUrl}/cp/sessions.html');" value="Cancel"/>
                            </td>
                            <td align="left"></td>
                        </tr>
                    </form:form>
                </table>
            </div> 
        </div> 
    </div>
</div>
<script type="text/javascript">
$(document).ready(function() {
    sz_Response = "${sz_Response}";
    if (sz_Response !== "")
    {
        alert(sz_Response);
    }

    $('#year').datepicker({
        showOn: "button",
        buttonImage: "${assetsUrl}/images/calendar.gif",
        buttonImageOnly: true,
        changeYear: true,
        onClose: function() {
            var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            var iNextYear = parseInt(iYear) + 1;
            $(this).val(iYear + '-' + iNextYear);
        },
        beforeShow: function() {
            if ((selDate = $(this).val()).length > 0)
            {
                iYear = selDate.substring(0, selDate.length - 5);
                $(this).datepicker('option', 'defaultDate', new Date(iYear, 1));
                iNextYear = parseInt(iYear) + 1;
                $(this).val(iYear + '-' + iNextYear);
            }
        }
    });
});
</script>